<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>行内块元素不对齐</title>
    <style>
    span{
        /* 设置垂直相对对齐，适用于行内元素跟行内块之间不对齐时 */
        vertical-align: middle;
    }
    img{
        width: 50px;
        vertical-align: middle;
    }
    p{
        /* 当行高等于高度时，文字垂直居中 */
        height: 100px;
        line-height: 100px;
        background: papayawhip;
    }
    div{
        width: 500px;
        height: 500px;
        background: powderblue url(timg1.gif) no-repeat center center;
    }
    </style>
</head>
<body>
    <span>文字</span><img src="timg1.gif" alt="">
    <p>垂直居中</p>
    <div></div>
</body>
</html>